package com.taotao.sso.service;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.taotao.sso.pojo.User;

@Service
public class UserService {
	

	
	@Autowired
	private RedisService redisService;
	
	
	private static final ObjectMapper MAPPER=new ObjectMapper();
	

	



	

	
	/**
	 * 用户登录	 * 
	 * @param user
	 * @return
	 * @throws JsonProcessingException 
	 */
	public String login(HttpServletRequest request) throws JsonProcessingException {
		
		
		HttpSession sessin=request.getSession();
		if(sessin.getAttribute("hello")==null){
		sessin.setAttribute("hello", sessin.getId());
		sessin.setAttribute("yyy", "sss");
		
		sessin.setMaxInactiveInterval(10);
		}
		System.out.println(sessin.getAttribute("hello"));
		
		
		redisService.set("123456", "ss55555");
		
	
		
		

		
		return (String) sessin.getAttribute("hello")+"---3";
	}

	

	
}
